home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 003.dms / 003.adf / TEXT / chapter20.txt < prev    next >
Text File  |  1992-09-02  |  8KB  |  309 lines

  1.  
  2.               The Absolute Beginners Guide To Amos
  3.               -------------------------------------
  4.                          Chapter Twenty
  5.                          --------------
  6.  
  7. We are now going to take a look at a few more mouse commands and take our
  8. first look at the joystick commands offered by Amos.
  9.  
  10.  
  11. LIMIT MOUSE x1,y1 TO x2,y2
  12. --------------------------
  13. This command LIMITs the MOUSE pointer to any area of the screen, this can be
  14. useful, if for example, you have a control panel on screen.  As you would 
  15. expect x1,y1 are the coordinates for the top left hand corner of the box
  16. and x2,y2 is the bottom right hand corner of the box area to be LIMITed.
  17. The coordinates for this command must be in hardware coordinates these are
  18. different to screen coordinates. Here is an alternative way to LIMIT the 
  19. MOUSE using the normal screen coordinates:
  20.  
  21. LIMIT MOUSE XHARD(X1),YHARD(Y1) TO XHARD(X2),YHARD(Y2)
  22. -----------------------------------------------------
  23. What we are doing is asking Amos to convert the screen coordinates into
  24. hardware coordinates for us, a lot easier.  
  25.  
  26.  
  27. The LIMIT MOUSE command used on it`s own will restore the mouse pointer to 
  28. it`s original full screen limit.
  29.  
  30.  
  31. X MOUSE
  32. -------
  33. Y MOUSE
  34. -------
  35. Returns the value of the X or Y mouse positions in hardware coordinates.
  36. See EXAMPLE20.Amos for an ample demonstration of these commands.
  37.  
  38.                 ------------------------------------
  39.  
  40.  
  41. OK now a look at the joystick commands:
  42.  
  43. FIRE (port number)
  44. ------------------
  45.  
  46. This command tests if the FIRE button has been pressed.  
  47. FIRE must be followed by the port number to be tested in brackets:
  48.  
  49. X=FIRE(1)
  50.  
  51. The port on the right hand side of your Amiga (mouse port) is port 0 and the
  52. normal joystick port (left side) is port 1.
  53. The value returned in X will be -1 (minus one) if the fire button has been
  54. pressed otherwise it will be 0, so a typical line in a game could be:
  55.  
  56. IF FIRE(1) then SHOOT
  57.  
  58. We do not need the -1 in the above line as -1 stands for true and the THEN
  59. part of the statement will only be executed if the IF part is true,
  60. if the IF part was false (0) then the THEN part will be ignored.
  61. remember the (1) is the port number.
  62.  
  63.  
  64.  
  65. The rest of these joystick commands work exactly the same:
  66.  
  67. X=JLEFT (port number)
  68.  
  69. X=JRIGHT (port number) 
  70.  
  71. X=JUP (port number)
  72.  
  73. X=JDOWN (port number)
  74.  
  75.  
  76.  
  77.               ----------------------------------- 
  78.  
  79. The following are the latest commands we have looked at and a brief 
  80. description of each.
  81.  
  82.  
  83. BAR            Draw a filled rectangle
  84.  
  85. BOX            Draw a hollow rectangle
  86.  
  87. CIRCLE         Draw a circle 
  88.  
  89. CHIP FREE      Returns amount of free Chip memory left
  90.  
  91. DFREE          Returns available bytes left on current disk
  92.  
  93. DIR$           Change current directory
  94.  
  95. DIM            Dimension an array
  96.  
  97. DRAW           Draw a straight line
  98.  
  99. END PROC       This must be the last instruction of every procedure
  100.  
  101. EXIST          Enquire if a file or disk exists
  102.  
  103. FAST FREE      Returns amount of FAST memory available for use
  104.  
  105. FIRE           Test if the joystick FIRE button has been pressed
  106.  
  107. FREE           Returns available space left in variable buffer
  108.  
  109. GLOBAL         Sets defined variables to be used inside and outside of procs
  110.  
  111. JDOWN          Test for joystick down
  112.  
  113. JLEFT          Test for joystick left
  114.  
  115. JRIGHT         Test for joystick right
  116.  
  117. JUP            Test for joystick up
  118.  
  119. KILL           Delete a file permanently
  120.  
  121. LDIR           Lists a directory of the current disk to the printer
  122.  
  123. LIMIT MOUSE    LIMIT the MOUSE pointer to a defined rectangle of the screen
  124.  
  125. LLIST         *Lists a basic program to the printer
  126.  
  127. LPRINT         Print a string of text to the printer 
  128.  
  129. MKDIR          Create a folder or drawer on the current disk
  130.  
  131. PLOT           Plot a pixel of colour onto the screen
  132.  
  133. PROCEDURE      Create a procedure 
  134.  
  135. POP PROC       Abort a procedure before it`s natural end
  136.  
  137. READ           Used to read data statements, usually for DIMensioned arrays
  138.  
  139. RENAME         Rename a file
  140.  
  141. SORT           Sort a dimensioned array in alpha or numerical order
  142.  
  143. XGR            Returns the X value of graphics cursors current position
  144.  
  145. XHARD          Converts screen to hardware coordinates
  146.  
  147. XMOUSE         Returns the X value of the mouse pointer in hardware coords
  148.  
  149. YGR            Returns the Y value of graphics cursors current position
  150.  
  151. YHARD          Converts screen coordinates to hardware coordinates
  152.  
  153. YMOUSE         Returns the Y value of the mouse pointer in hardware coords
  154.  
  155.  
  156.  
  157.  
  158. *LList does not work on the original Amos package, if you want to print your
  159. program listing to the printer select it as a block and use PRINT BLOCK from
  160. the menus at the top of the screen.
  161.  
  162. ----------------------------------------------------------------------------
  163.  
  164.  
  165.        And here is the very last of the Self TEST Quizzes.
  166.        ===================================================
  167.  
  168.  
  169. Q 1. What does the command BAR achieve?
  170.  
  171.   a) Draws a filled rectangle
  172.   b) Draws a hollow rectangle
  173.   c) Draws a triangle
  174.  
  175.  
  176. Q 2. Which command would you use to delete a file from a disk?
  177.  
  178.   a) Delete
  179.   b) DIR$
  180.   c) Kill
  181.  
  182.  
  183. Q 3. Who is the odd man out?
  184.  
  185.   a) DIM
  186.   b) Read
  187.   c) Plot
  188.  
  189.  
  190. Q 4. What would the following line achieve?
  191.      
  192.      MKDIR "DF0: KILL"
  193.  
  194.   a) Creates a drawer on DF0:
  195.   b) Deletes all the files on DF0:
  196.   c) Installs the disk in DF0:
  197.  
  198.  
  199. Q 5. How would you break out of a procedure before the END PROC command?
  200.  
  201.   a) GOSUB
  202.   b) GOTO
  203.   c) POP PROC  
  204.  
  205.  
  206. Q 6.  What does the last parameter (c) in PLOT x,y,c stand for?              
  207.  
  208.   a) Clear
  209.   b) Colour
  210.   c) Cls
  211.  
  212.  
  213. Q 7.  What do the XGR and YGR commands achieve?
  214.  
  215.   a) Return the graphics cursors current coordinates
  216.   b) Return the text cursors current coordinates
  217.   c) return the disk drives warp speed
  218.  
  219.  
  220. Q 8.  What is wrong with the following?
  221.  
  222.       DRAW 100,10
  223.  
  224.   a) There are two parameters missing
  225.   b) The syntax is correct
  226.   c) There is one parameter missing.
  227.  
  228.  
  229. Q 9. Who is the odd man out?
  230.  
  231.   a) PROCEDURE
  232.   b) POP PROC
  233.   c) EXIST 
  234.  
  235.  
  236. Q10. What does the SORT command achieve?
  237.  
  238.   a) Sorts a dimensioned array into order
  239.   b) Sorts memory chunks into slices
  240.   c) Sorts out your personal life
  241.  
  242.  
  243.               -----------------------------------
  244.  
  245.  
  246.  
  247. This seems as good a time as any to have a quick look at key press commands.
  248.  
  249. We are familiar with WAIT KEY and CLEAR KEY but what if we want to know the
  250. exact key that was pressed by the user, from a menu of options maybe.
  251. The following short piece of code I have used many many times in my basic
  252. programs over the years, make a note as I am sure you will use it too.
  253.  
  254. CLEAR KEY: K$="": WHILE K$="": K$=INKEY$: WEND
  255.  
  256. This line will CLEAR the KEYboard buffer of any previous key presses and
  257. start looping between WHILE and WEND until a key is pressed, when this 
  258. happens the loop will be broken and K$ will contain the key that was pressed.
  259.  
  260. Your next lines could read something like this:
  261.  
  262. IF K$="1" THEN DOSOMETHING
  263. IF K$="Q" THEN QUITGAME
  264.  
  265. etc.
  266.  
  267. There are lots of different ways of achieving the same result but I prefer
  268. this as it`s simple and effective.
  269.  
  270.             -----------------------------------------
  271.  
  272. Well that is the end of this Absolute beginners tutorial.  By now you should
  273. have the grasp of quite a few of Amos`s commands, there are many more 
  274. commands and techniques to discover, I have barely scratched the surface.
  275.  
  276. I have tried to keep it as simple as possible and as a result not all of the
  277. uses of commands have been covered this is, in my opinion, the best way to 
  278. learn as confusion over a certain command makes most people shy away from it 
  279. for good, where as a small understanding of that command may lead to the 
  280. person confidently making further investigations themselves.
  281.  
  282. I hope you have enjoyed this tutorial and have profited from it, weather I
  283. write Vol 2 of this guide will depend on how popular it is and if I can get
  284. the time together.
  285.  
  286.  
  287. Load up the Amos programs in the EXTRAS drawer on this disk.  There are some
  288. excellent programs in there that you can learn a lot from.  Hope you enjoy
  289. them.
  290.  
  291. Before I go here are the answers to the self testing quiz:
  292.  
  293.                           1.A    6. B
  294.  
  295.                           2.C    7. A
  296.  
  297.                           3.C    8. A
  298.  
  299.                           4.A    9. C
  300.  
  301.                           5.C   10. A
  302.   
  303.  
  304.  
  305. Be seeing you!
  306.  
  307.  
  308. End of tutorial.  
  309.